package _0_语法._4_循环._2_双循环;

public class _12_阶乘2_2 {

    public static void main(String[] args) {
        double sum = 0.0;   // 和
        double product;     // 乘积

        // 执行次数
        for (int i = 0; i < 10; i++) {
            System.out.println("第 " + (i + 1) +" 轮");
            product = 1.0;
            // 每次执行的阶乘次数
            for (int j = 0; j <= i; j++) {
                product = product * (j + 1);
                if(j != i){
                    System.out.print((j + 1) + "*");
                }
                else {
                    System.out.print(j + 1);
                }
            }
            sum = sum + 1 / product;
//            sum = sum + product;
            System.out.println("=" + sum);
        }
    }
}
